from selenium.webdriver.common.by import By

from wewrok_app_po.Base.wework_app import WeWorkApp
from wewrok_app_po.Page.person_info import PersonInfo


class SearchPage(WeWorkApp):
    _RESULT = By.XPATH, "//*[@text='无搜索结果']"
    _INPUT_NAME=By.XPATH, "//*[@text='搜索']"
    _CLICK = By.XPATH, "//*[@resource-id = 'com.tencent.wework:id/f4l']/child::*[1]"
    def input_name(self,new_name):
        # 输入姓名
        self.find_and_send_keys(*self._INPUT_NAME,new_name)
        # 点击联想到的联系人
        self.wait_for_text(self.driver, '联系人')
        self.driver.implicitly_wait(10)
        self.find_and_click(*self._CLICK)
        return PersonInfo(self.driver)

    def get_toast(self):
        res = self.find_and_text(*self._RESULT)
        return res